Edge-preserving filtering method and apparatus

ABSTRACT

An edge-preserving filtering method and apparatus. The edge-preserving filtering method includes: acquiring an upper edge pixel P(x,y−n), a lower edge pixel P(x,y+m), (m+n) left edge pixels P(x−p,y′), and (m+n) right edge pixels P(x+q,y′) of a pixel to be filtered P(x,y), wherein “x”, “y”, “m”, “n”, “p” and “q” are all positive integers, and “y” takes an integer larger than “y−n” and less than “y+m” in turn; acquiring a filtered pixel value of the pixel to be filtered by using pixel values of the pixel to be filtered, the upper edge pixel, the lower edge pixel, the left edge pixels and the right edge pixels. The edge-preserving filtering method and apparatus in accordance with an embodiment utilize edge information around the pixel to be filtered to swiftly acquire a set of pixels for filtering the pixel to be filtered, and thus implement edge-persevering filtering.

CROSS-REFERENCE TO RELATED APPLICATIONS

This application is based upon and claims the benefit of foreignpriority of Chinese Patent Application No. 201210092488.6, filed on Mar.27, 2012, the entire contents of which are incorporated herein byreference.

FIELD OF THE INVENTION

The invention relates to image processing, and in particular to anedge-preserving filtering method and apparatus.

BACKGROUND

Image filtering, i.e., restraining noises of an image while preservingspecific characteristics as more as possible of the image, is anecessary operation in image processing, and its processing resultdirectly affects effectiveness and reliability of following imageprocessing and analysis.

Due to imperfection of imaging systems, transmission mediums andrecording devices and so on, digital images usually suffer frompollutions of various noises when they are formed, transmitted andrecorded. Additionally, in some image processing steps, when an inputobject is worse than expected in image quality, noises also would beintroduced to a result image. These noises usually appear as isolatedpixels or pixel blocks that would cause comparatively strong visualeffect on an image. For digital image signals, noises usually appear asmaximum or minimum extreme values. The extreme values affect real grayvalues of image pixels through adding or subtracting computation, whichresults in bright or dim spot interferences on the image, greatlydegrades the quality of the image and affects subsequent works such asimage restoration, segmentation, feature extraction, imageidentification and so on.

To construct a filter capable of restraining noises effectively, thefollowing two basic problems must be taken into consideration: (1)removing noises in an image effectively; and (2) preserving shape, size,geometry and topology characteristics of the image.

Edge-preserving filtering technique is widely used in digital imageprocessing. This technique can effectively preserve edge information ofan image while filtering the image. Traditional edge-persevering filterscomprise bilateral filters, weighted least squares (WLS) filters and soon. The computation of these filters is relatively complex, so it isdifficult for the filters to implement real-time processing.

SUMMARY OF THE INVENTION

In view of the problems stated above, the invention provides a noveledge-preserving filtering method and apparatus.

An edge-preserving filtering method in accordance with an embodiment ofthe invention, comprising: acquiring an upper edge pixel P(x,y−n), alower edge pixel P(x,y+m), (m+n) left edge pixels P(x−p,y′), and (m+n)right edge pixels P(x+q,y′) of a pixel to be filtered P(x,y), wherein“x”, “y”, “m”, “n”, “p” and “q” are all positive integers, and “y”'takes an integer larger than “y−n” and less than “y+m” in turn;acquiring a filtered pixel value of the pixel to be filtered by usingpixel values of the pixel to be filtered, the upper edge pixel, thelower edge pixel, the left edge pixels and the right edge pixels.

An edge-preserving filtering apparatus in accordance with an embodimentof the invention, comprising: an edge acquiring unit for acquiring anupper edge pixel P(x,y−n), a lower edge pixel P(x,y+m), (m+n) left edgepixels P(x−p,y′), and (m+n) right edge pixels P(x+q,y′) of a pixel to befiltered P(x,y), wherein “x”, “y”, “m”, “n”, “p” and “q” are allpositive integers, and “y”' takes an integer larger than “y−n” and lessthan “y+m” in turn; a pixel filtering unit for acquiring a filteredpixel value of the pixel to be filtered by using pixel values of thepixel to be filtered, the upper edge pixel, the lower edge pixel, theleft edge pixels and the right edge pixels.

The edge-preserving filtering method and apparatus in accordance with anembodiment of the invention utilize edge information around the pixel tobe filtered to swiftly acquire a set of pixels for filtering the pixelto be filtered, and thus implements edge-persevering filtering.

DESCRIPTION OF THE DRAWINGS

The patent or application file contains at least one drawing executed incolor. Copies of this patent or patent application publication withcolor drawing(s) will be provided by the Office upon request and paymentof the necessary fee.

The invention can be better understood through the following descriptionin conjunction with the accompanying drawings, wherein:

FIG. 1 illustrates a block diagram of an edge-preserving filteringapparatus in accordance with an embodiment of the invention;

FIG. 2 illustrates a flow diagram of an edge-preserving filtering methodin accordance with an embodiment of the invention; and

FIG. 3 illustrates exemplary edge information for edge-perseveringfiltering a pixel to be filtered.

DETAILED EMBODIMENTS

Next, characteristics and exemplary embodiments of various aspects ofthe invention will be described in detail. The following descriptionscover many specific details so as to provide comprehensive understandingof the invention. However, it would be obvious for those skilled in theart that the invention may be implemented in absence of some of thespecific details. The following descriptions of embodiments are merelyfor providing clearer understanding of the invention through showingexamples of the invention. The invention is not limited to any specificconfiguration and algorithm provided below; and instead, it covers anymodification, substitution, and improvement of corresponding elements,components and algorithms without departing from the spirit of theinvention.

The invention provides a quick edge-preserving filtering method andapparatus. The edge-preserving filtering method and apparatus inaccordance with an embodiment of the invention utilize edge informationaround a pixel to be filtered to swiftly acquire a set of pixels forfiltering, and thus implements edge-persevering filtering.

FIG. 1 illustrates a block diagram of an edge-preserving filteringapparatus in accordance with an embodiment of the invention. FIG. 2illustrates a flow diagram of an edge-preserving filtering method inaccordance with an embodiment of the invention. Next, theedge-preserving filtering method and apparatus in accordance with anembodiment of the invention will be described in detail with referenceto FIG. 1 and FIG. 2.

As shown in FIG. 1, the edge-preserving filtering apparatus inaccordance with an embodiment of the invention comprises an edgeacquiring unit 102 and a pixel filtering unit 104. The edge acquiringunit 102 is used for acquiring an upper edge pixel P(x,y−n), a loweredge pixel P(x,y+m), (m+n) left edge pixels P(x−p,y′), and (m+n) rightedge pixels P(x+q,y′) of a pixel to be filtered P(x,y) (i.e.,implementing step S202). The pixel filtering unit 104 is used foracquiring a filtered pixel value of the pixel to be filtered by usingpixel values of the pixel to be filtered and its upper edge pixel, loweredge pixel, left edge pixels and right edge pixels (i.e., implementingstep S204). It should be noted that “x”, “y”, “m”, “n”, “p” and “q” areall positive integers, and “y” takes an integer larger than “y−n” andless than “y+m” in turn.

Next, specific processing of the edge acquiring unit 102 and the pixelfiltering unit 104 will be described.

1. The edge acquiring unit 102 starts from the pixel to be filteredP(x,y), and acquires its edge information (i.e., acquiring its edgepixels).

Acquiring the edge pixels comprises two passes of acquiring edge pixelsin the vertical direction and acquiring edge pixels in the horizontaldirection. Here, it is assumed that intensity values of three colorchannels of the pixel to be filtered P(x,y) are r(x,y), g(x,y) andb(x,y).

Firstly, an upper edge pixel in the vertical direction of the pixel tobe filtered P(x,y) is acquired. Specifically, judgment is made withrespect to pixels P(x,y−1), P(x,y−2), . . . , P(x,y−n) in turn. IfP(x,y−n) meets the following conditions, then P(x,y−n) is judged as theupper edge pixel of the pixel to be filtered P(x,y):

${\sum\limits_{i = 1}^{n}\; ( {{{{r( {x,{y - i}} )} - {r( {x,{y - i + 1}} )}}} + {{{g( {x,{y - i}} )} - {g( {x,{y - i + 1}} )}}} + {{{b( {x,{y - i}} )} - {b( {x,{y - i + 1}} )}}}} )} \geq {thresh}$and${\sum\limits_{i = 1}^{n - 1}\; ( {{{{r( {x,{y - i}} )} - {r( {x,{y - i + 1}} )}}} + {{{g( {x,{y - i}} )} - {g( {x,{y - i + 1}} )}}} + {{{b( {x,{y - i}} )} - {b( {x,{y - i + 1}} )}}}} )} < {thresh}$

Then, a lower edge pixel in the vertical direction of the pixel to befiltered P(x,y) is acquired. Specifically, judgment is made with respectto pixels P(x,y+1), P(x,y+2), . . . , P(x,y+m) in turn. If P(x,y+m)meets the following conditions, then P(x,y+m) is judged as the loweredge pixel of the pixel to be filtered P(x,y):

${\sum\limits_{i = 1}^{m}\; ( {{{{r( {x,{y + i}} )} - {r( {x,{y + i - 1}} )}}} + {{{g( {x,{y + i}} )} - {g( {x,{y + i - 1}} )}}} + {{{b( {x,{y + i}} )} - {b( {x,{y + i - 1}} )}}}} )} \geq {thresh}$and${\sum\limits_{i = 1}^{m - 1}\; ( {{{{r( {x,{y + i}} )} - {r( {x,{y + i - 1}} )}}} + {{{g( {x,{y + i}} )} - {g( {x,{y + i - 1}} )}}} + {{{b( {x,{y + i}} )} - {b( {x,{y + i - 1}} )}}}} )} < {thresh}$

Next, for each pixel P(x,y′) (y−n<y′<y+m) between the upper and loweredge pixels of the pixel to be filtered P(x,y), a left edge pixel in thehorizontal direction of the pixel P(x,y′) (i.e., a left edge pixel ofthe pixel to be filtered P(x,y)) is acquired. Specifically, judgment ismade with respect to pixels P(x−1,y′), P(x−2,y′), . . . , P(x−p,y′) inturn. If P(x−p,y′) meets the following conditions, then P(x−p,y′) isdetermined as the left edge pixel of the pixel P(x,y′):

${\sum\limits_{i = 1}^{p}\; ( {{{{r( {{x - p},y^{\prime}} )} - {r( {{x - p + 1},y^{\prime}} )}}} + {{{g( {{x - i},y^{\prime}} )} - {g( {{x - i + 1},y^{\prime}} )}}} + {{{b( {{x - i},y^{\prime}} )} - {b( {{x - i + 1},y^{\prime}} )}}}} )} \geq {thresh}$and${\sum\limits_{i = 1}^{p - 1}\; ( {{{{r( {{x - p},y^{\prime}} )} - {r( {{x - p + 1},y^{\prime}} )}}} + {{{g( {{x - i},y^{\prime}} )} - {g( {{x - i + 1},y^{\prime}} )}}} + {{{b( {{x - i},y^{\prime}} )} - {b( {{x - i + 1},y^{\prime}} )}}}} )} < {thresh}$

Next, for each pixel P(x,y′) (y−n<y′<y+m) between the upper and loweredge pixels of the pixel to be filtered P(x,y), a right edge pixel inthe horizontal direction of the pixel P(x,y′) (i.e., a right edge pixelof the pixel to be filtered P(x,y)) is found out. Specifically, judgmentis made with respect to pixels P(x+1, y′), P(x+2,y′), . . . , P(x+q,y′)in turn. If P(x+q,y′) meets the following conditions, then P(x+q,y′) isjudged as the right edge pixel in the horizontal direction of the pixelP(x,y′):

${\sum\limits_{i = 1}^{q}\; ( {{{{r( {{x + q},y^{\prime}} )} - {r( {{x + q - 1},y^{\prime}} )}}} + {{{g( {{x + q},y^{\prime}} )} - {g( {{x + q - 1},y^{\prime}} )}}} + {{{b( {{x + q},y^{\prime}} )} - {b( {{x + q - 1},y^{\prime}} )}}}} )} \geq {thresh}$and${\sum\limits_{i = 1}^{q - 1}\; ( {{{{r( {{x + q},y^{\prime}} )} - {r( {{x + q - 1},y^{\prime}} )}}} + {{{g( {{x + q},y^{\prime}} )} - {g( {{x + q - 1},y^{\prime}} )}}} + {{{b( {{x + q},y^{\prime}} )} - {b( {{x + q - 1},y^{\prime}} )}}}} )} < {thresh}$

It should be noted that the thresh for acquiring the upper edge pixel,the lower edge pixel, the left edge pixels and the right edge pixels ofthe pixel to be filtered is a same constant.

FIG. 3 illustrates exemplary edge information for edge-perseveringfiltering the pixel to be filtered. As can be seen from FIG. 3, the setof pixels for edge-persevering filtering the pixel to be filteredcomprise the pixel to be filtered and its left edge pixels, right edgepixels, upper pixel and lower pixel.

2. The pixel filtering unit 104 utilizes pixels in the set of pixels toimplement edge-persevering filtering for the pixel to be filtered.

Specifically, the filtered pixel value of the pixel to be filtered iscalculated by weighted averaging pixel values of all pixels in the setof pixels described above (e.g., intensities of R, G or B channels). Itis assumed that the number of pixels in the above set of pixels is “n”,then the filtered pixel value of the pixel to be filtered is thefollowing:

$p = {\sum\limits_{i = 0}^{n - 1}\; {k_{i}p_{i}}}$${\sum\limits_{i = 0}^{n - 1}\; k_{i}} = 1$

As can be seen, the edge-preserving filtering method and apparatus inaccordance with an embodiment of the invention utilize the edgeinformation around the pixel to be filtered to swiftly acquire a set ofpixels for filtering the pixel to be filtered, and thus implementsedge-persevering filtering.

Although the invention has been described with reference to detailedembodiments of the invention, those skilled in the art would understandthat modifications, combinations and changes may be done to the specificembodiments without departing from the scope and spirit of the inventionas defined by the appended claims and the equivalents thereof.

Hardware or software may be used to perform the steps as required. Itshould be noted that under the premise of not departing from the scopeof the invention, the steps may be amended, added to or removed from theflow chart provided by the description. Generally, a flow chart is onlyone possible sequence of basic operations performing functions.

Embodiments of the invention may be implemented using a generalprogrammable digital computer, a specific integrated circuit,programmable logic devices, a field-programmable gate array, andoptical, chemical, biological, quantum or nano-engineering systems,components and institutions. Generally, functions of the invention maybe realized by any means known to those skilled in the art. Distributedor networked systems, components and circuits may be used. And data maybe transmitted wired, wirelessly, or by any other means.

It shall be realized that one or more elements illustrated in theaccompanying drawings may be realized in a more separated or moreintegrated method; they would even be allowed to be removed or disabledunder some conditions. Realizing programs or codes capable of beingstored in machine readable media so as to enable a computer to performthe aforementioned method also fails within spirit and scope of theinvention.

Additionally, any arrows in the accompanying drawings shall be regardedas being exemplary rather than limiting. And unless otherwise indicatedin detail, combinations of components and steps shall be regarded asbeing recorded when terms are foreseen as leading unclearness to theability for separating or combining.

What is claimed is:
 1. An edge-preserving filtering method, comprising:acquiring an upper edge pixel P(x,y−n), a lower edge pixel P(x,y+m),(m+n) left edge pixels P(x−p,y′), and (m+n) right edge pixels P(x+q,y′)of a pixel to be filtered P(x,y), wherein “x”, “y”, “m”, “n”, “p” and“q” are all positive integers, and “y”' takes an integer larger than“y−n” and less than “y+m” in turn; acquiring a filtered pixel value ofthe pixel to be filtered by using pixel values of the pixel to befiltered, the upper edge pixel, the lower edge pixel, the left edgepixels and the right edge pixels.
 2. The edge-preserving filteringmethod of claim 1, characterized in that the processing of acquiring thefiltered pixel value of the pixel to be filtered comprises: calculatinga weighted average of the pixel values of the pixel to be filtered, theupper edge pixel, the lower edge pixel, the left edge pixels and theright edge pixels, as the filtered pixel value of the pixel to befiltered.
 3. The edge-preserving filtering method of claim 1,characterized in that the processing of acquiring the upper edge pixelP(x,y−n) comprises: calculating a sum of absolute gradients of threecolor channels of pixels P(x,y−1), P(x,y−2), . . . , P(x,y−n+1),P(x,y−n) above the pixel to be filtered P(x,y); if the sum of theabsolute gradients of three color channels of the pixels P(x,y−1),P(x,y−2), . . . , P(x,y−n+1), P(x,y−n) is not less than a predeterminedthreshold, and a sum of absolute gradients of three color channels ofthe pixels P(x,y−1), P(x,y−2), . . . , P(x,y−n+1) is less than thepredetermined threshold, then determining that the pixel P(x,y−n) is theupper edge pixel of the pixel to be filtered P(x,y).
 4. Theedge-preserving filtering method of claim 1, characterized in that theprocessing of acquiring the lower edge pixel P(x,y+m) comprises:calculating a sum of absolute gradients of three color channels ofpixels P(x,y+1), P(x,y+2), . . . , P(x,y+m−1), P(x,y+m) below the pixelto be filtered P(x,y); if the sum of the absolute gradients of threecolor channels of the pixels P(x,y+1), P(x,y+2), . . . , P(x,y+m−1),P(x,y+m) is not less than the predetermined threshold, and a sum ofabsolute gradients of three color channels of the pixels P(x,y+1),P(x,y+2), . . . , P(x,y+m−1) is less than the predetermined threshold,then determining that the pixel P(x,y+m) is the lower edge pixel of thepixel to be filtered P(x,y).
 5. The edge-preserving filtering method ofclaim 1, characterized in that the processing of acquiring a left edgepixel P(x−p,y′) of the pixel to be filtered P(x,y) comprises:calculating a sum of absolute gradients of three color channels ofpixels P(x−1, y′), P(x−2, y′), . . . , P(x−p+1,y′), P(x−p,y′) on theleft of the pixel P(x,y′); if the sum of the absolute gradients of threecolor channels of the pixels P(x−1, y′), P(x−2, y′), . . . ,P(x−p+1,y′), P(x−p,y′) is not less than the predetermined threshold, anda sum of absolute gradients of three color channels of the pixelsP(x−1,y′), P(x−2, y′), . . . , P(x−p+1,y′) is less than thepredetermined threshold, then determining that the pixel P(x−p,y′) is aleft edge pixel of the pixel to be filtered P(x,y).
 6. Theedge-preserving filtering method of claim 1, characterized in that theprocessing of acquiring a right edge pixel P(x+q,y′) of the pixel to befiltered P(x,y) comprises: calculating a sum of absolute gradients ofthree color channels of pixels P(x+1, y′), P(x+2, y′), . . . ,P(x+q−1,y′), P(x+q,y′) on the right of the pixel P(x,y′); if a sum ofabsolute gradients of three color channels of the pixels P(x+1,y′),P(x+2,y′), . . . , P(x+q−1,y′), P(x+q,y′) is not less than thepredetermined threshold, and a sum of absolute gradients of three colorchannels of the pixels P(x+1,y′), P(x+2, y′), . . . , P(x+q−1,y′) isless than the predetermined threshold, then determining that the pixelP(x+q,y′) is a right edge pixel of the pixel to be filtered P(x,y). 7.An edge-preserving filtering apparatus, comprising: an edge acquiringunit for acquiring an upper edge pixel P(x,y−n), a lower edge pixelP(x,y+m), (m+n) left edge pixels P(x−p,y′), and (m+n) right edge pixelsP(x+q,y′) of a pixel to be filtered P(x,y), wherein “x”, “y”, “m”, “n”,“p” and “q” are all positive integers, and “y”' takes an integer largerthan “y−n” and less than “y+m” in turn; a pixel filtering unit foracquiring a filtered pixel value of the pixel to be filtered by usingpixel values of the pixel to be filtered, the upper edge pixel, thelower edge pixel, the left edge pixels and the right edge pixels.
 8. Theedge-preserving filtering apparatus of claim 7, characterized in thatthe pixel filtering unit calculates a weighted average of the pixelvalues of the pixel to be filtered, the upper edge pixel, the lower edgepixel, the left edge pixels and the right edge pixels, as the filteredpixel value of the pixel to be filtered.
 9. The edge-preservingfiltering apparatus of claim 7, characterized in that the edge acquiringunit acquires the upper edge pixel P(x,y−n) by the following processing:calculating a sum of absolute gradients of three color channels ofpixels P(x,y−1), P(x,y−2), . . . , P(x,y−n+1), P(x,y−n) above the pixelto be filtered P(x,y); if the sum of the absolute gradients of threecolor channels of the pixels P(x,y−1), P(x,y−2), . . . , P(x,y−n+1),P(x,y−n) is not less than a predetermined threshold, and a sum ofabsolute gradients of three color channels of the pixels P(x,y−1),P(x,y−2), . . . , P(x,y−n+1) is less than the predetermined threshold,then determining that the pixel P(x,y−n) is the upper edge pixel of thepixel to be filtered P(x,y).
 10. The edge-preserving filtering apparatusof claim 7, characterized in that the edge acquiring unit acquires thelower edge pixel P(x,y+m) by the following processing: calculating a sumof absolute gradients of three color channels of pixels P(x,y+1),P(x,y+2), . . . , P(x,y+m−1), P(x,y+m) below the pixel to be filteredP(x,y); if the sum of the absolute gradients of three color channels ofthe pixels P(x,y+1), P(x,y+2), . . . , P(x,y+m−1), P(x,y+m) is not lessthan the predetermined threshold, and a sum of absolute gradients ofthree color channels of the pixels P(x,y+1), P(x,y+2), . . . ,P(x,y+m−1) is less than the predetermined threshold, then determiningthat the pixel P(x,y+m) is the lower edge pixel of the pixel to befiltered P(x,y).
 11. The edge-preserving filtering apparatus of claim 7,characterized in that the edge acquiring unit acquires a left edge pixelP(x−p,y′) of the pixel to be filtered P(x,y) by the followingprocessing: calculating a sum of absolute gradients of three colorchannels of pixels P(x−1, y′), P(x−2, y′), . . . , P(x−p+1,y′),P(x−p,y′) on the left of the pixel P(x,y′); if the sum of the absolutegradients of three color channels of the pixels P(x−1, y′), P(x−2, y′),. . . , P(x−p+1,y′), P(x−p,y′) is not less than the predeterminedthreshold, and a sum of the absolute gradients of three color channelsof the pixels P(x−1,y′), P(x−2, y′), . . . , P(x−p+1,y′) is less thanthe predetermined threshold, then determining that the pixel P(x−p,y′)is a left edge pixel of the pixel to be filtered P(x,y).
 12. Theedge-preserving filtering apparatus of claim 7, characterized in thatthe edge acquiring unit acquires a right edge pixel P(x+q,y′) of thepixel to be filtered P(x,y) by the following processing: calculating asum of absolute gradients of three color channels of pixels P(x+1, y′),P(x+2, y′), . . . , P(x+q−1,y′), P(x+q,y′) on the right of the pixelP(x,y′); if the sum of absolute gradients of the pixels P(x+1,y′),P(x+2,y′), . . . , P(x+q−1,y′), P(x+q,y′) is not less than thepredetermined threshold, and a sum of the absolute gradients of threecolor channels of the pixels P(x+1, y′), P(x+2, y′), . . . , P(x+q−1,y′)is less than the predetermined threshold, then determining that thepixel P(x+q,y′) is a right edge pixel of the pixel to be filteredP(x,y).